<template>
	<view class="gui-margin">

		<gui-empty v-if="shop_list==''">
			<view slot="img" class="gui-flex gui-rows gui-justify-content-center">
				<!-- 请根据您的项目要求制作并更换为空图片 -->
				<image class="gui-empty-img" :src="empty_img">
				</image>
			</view>
			<text slot="text" class="gui-text-small gui-block-text gui-text-center gui-margin-top"
				style="color:#9DABFF;">暂无数据</text>
		</gui-empty>

		<view class="gui-card-body gui-border-b gui-flex gui-rows gui-nowrap gui-margin-top" v-for="(item,index) in shop_list"
			:key="index">
			<image :src="item.logo" style="width: 150rpx;height: 150rpx;" @tap="goto_shop_details(item.shop_id)"></image>
			<view class="gui-card-desc">
				<view class="gui-flex gui-rows gui-nowrap gui-align-items-center">
					<text class="gui-card-name">{{item.name}}</text>
					<!-- <text class="gui-text-small gui-color-blue">补充信息</text> -->
				</view>

				<text class="gui-card-text gui-block-text" style="margin-top:10rpx;"
					@tap="daohang(item.longitude,item.latitude)">{{item.address}}</text>
				<text class="gui-card-text gui-block-text"
					@tap="callMobile(item.phone_number)">{{item.phone_number}}</text>
			</view>

			<gui-tags text="解绑" bgClass="gui-bg-red" :size="26" :borderRadius="50" style="margin-top: 50rpx;" @tap="unbind_shop(item.shop_id)"></gui-tags>
		</view>
	</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				shop_list: '',
				empty_img: this.empty_img
			}
		},
		onLoad: function() {
			this.$globalMethod();
			this.teacher_shop_list();
		},
		methods: {
			goto_shop_details: function(id) {
				uni.navigateTo({
					url: "/pages/shop/shop_details?id=" + id
				})
			},
			unbind_shop(id){
				let _this = this;
				this.graceJS.post(
					this.serverUrl + '/api.teacher/unbind_shop', {
						shop_id: id
					}, {
				
					}, {
						token: _this.token
					},
					(res) => {
						// console.log(res);
				
						if (res.code == 0) {
							
							uni.showToast({
								title: res.msg,
								icon: 'success'
							})
							
							_this.teacher_shop_list();
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'error'
							})
						}
					},
					(e) => {
						console.log(e);
					}
				);
			},
			teacher_shop_list() {
				let _this = this;
				_this.graceJS.post(_this.serverUrl + '/api.shop/teacher_shop_list', {}, 'json', {
						'token': _this.token
					}, (res) => {
						if(res.code==0){
							_this.shop_list = res.data.list;
						}else{
							uni.showToast({
								title:res.msg,
								icon:'error'
								
							})
						}
					},
					(e) => {
						console.log(e);
					})
			},
			change2: function(e) {
				console.log(e);
			},
			maxSed: function() {
				uni.showToast({
					title: '最多可以选择2个哦',
					icon: 'none'
				})
			}
		}
	}
</script>
<style>
	.title1-margin {
		margin: 0 20rpx;
	}
	
	.button {
		width: 90rpx;
		height: 90rpx;
		line-height: 90rpx;
		border-radius: 8rpx;
		margin: 10rpx;
	}
	
	.button-text {
		font-size: 38rpx;
		text-align: center;
	}
	
	.demo {
		width: 210rpx;
		margin: 10rpx;
	}
	
	/* 卡片视图 */
	.gui-card-view {
		background-color: #FFFFFF;
		padding: 25rpx;
	}
	
	.gui-card-body {
		padding-bottom: 25rpx;
	}
	
	.gui-card-img {
		width: 100rpx;
		height: 100rpx;
		border-radius: 80rpx;
	}
	
	.gui-card-desc {
		width: 400rpx;
		margin-left: 25rpx;
		flex: 1;
	}
	
	.gui-card-name {
		font-size: 28rpx;
		color: #333333;
		line-height: 40rpx;
		margin-right: 20rpx;
	}
	
	.gui-card-text {
		line-height: 40rpx;
		font-size: 24rpx;
		color: #888888;
	}
	
	.gui-card-footer {
		margin-top: 25rpx;
	}
	
	.gui-card-footer-item {
		width: 100rpx;
		text-align: center;
		flex: 1;
		line-height: 38rpx;
		font-size: 26rpx;
		color: #666666;
	}
</style>